/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package skelbkim;

import com.thoughtworks.selenium.*;
import java.util.regex.Pattern;

/**
 *
 * @author laimis
 */
public class Nskelbimai extends SeleneseTestCase {

    public void setUp() throws Exception {
        setUp("http://nskelbimai.lt/", "*firefox");
    }

    public void newNotation(String noticeText, String phone, String name, String noticeTitle, String email) throws Exception {
        selenium.open("/");
        selenium.click("link=Įdėti skelbimą!");
        if (isPageLoude()) {
            selenium.select("cat", "label=Paslaugos");
            selenium.type("title", noticeTitle);
            selenium.type("price", "50");
            selenium.type("location", "Klaipeda");
            selenium.type("description", noticeText);
            selenium.type("name_owner", name);
            selenium.type("email", email);
            selenium.type("phone", phone);
        }
    }

    private boolean isPageLoude() {
        boolean result = true;
        while (!selenium.isElementPresent("//*[@id='submit']")) {
            selenium.waitForPageToLoad("5000");
        }
        return result;
    }
}
